#!/usr/bin/ruby -w

require "test/unit"
require "triangle.rb"

class TestTriangle < Test::Unit::TestCase
  # A triangle cannot be formed if the combined lengths of two sides are equal
  # to or less than the third side. Also, sides cannot be 0 or negative.
  def test_impossible_triangle
    assert_equal("Not a triangle", triangle?(1, 2, 4))
    assert_equal("Not a triangle", triangle?(8, 2, 4))
    assert_equal("Not a triangle", triangle?(1, 9, 2))

    assert_equal("Not a triangle", triangle?(0, 1, 2))
    assert_equal("Not a triangle", triangle?(0, 0, 0))
    assert_equal("Not a triangle", triangle?(-6, 1, 6))		
  end

  # An equilateral triangle has three sides of the same length, and that length
  # is more than 0.
  def test_equilateral
    assert_equal("Not a triangle", triangle?(0, 0, 0))
    assert_equal("Equilateral", triangle?(1, 1, 1))
    assert_equal("Equilateral", triangle?(8, 8, 8))
  end

  # A isosceles triangle has two sides that are equal in length, but not
  # three, since that would result in an equilateral triangle.
  def test_isosceles
    assert_equal("Isosceles", triangle?(5, 5, 2))
    assert_equal("Isosceles", triangle?(3, 7, 7))
    assert_equal("Isosceles", triangle?(5, 4, 5))
  end

  # A rectangular triangle has a corner of exactly 90 degrees.
  # If a triangle is rectangular the pythagoras theorem can be applied.
  def test_rectangular
    assert_equal("Rectangular", triangle?(3, 4, 5))
  end
end

# Indication of time spent: 2 hours
